<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lqlb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='zh'/>：</label>
                        <div class="layui-input-inline">
                            <input type="text" name="user.username" value="${params.user.username}" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="status" class="layui-select">
                                <option value="0"><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.status == 1}">selected</c:if>><fmt:message key='ksy'/></option>
                                <option value="2" <c:if test="${params.status == 2}">selected</c:if>><fmt:message key='yyw'/></option>
                                <option value="3" <c:if test="${params.status == 3}">selected</c:if>><fmt:message key='yzz'/></option>
                                <option value="4" <c:if test="${params.status == 4}">selected</c:if>><fmt:message key='ygq'/></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <table class="layui-table" lay-size="sm">
                <thead>
                    <tr>
                        <th><fmt:message key='xh'/></th>
                        <th><fmt:message key='gwkkh'/></th>
                        <th><fmt:message key='zh'/></th>
                        <th><fmt:message key='gwkye'/></th>
                        <th><fmt:message key='ly'/></th>
                        <th><fmt:message key='zt'/></th>
                        <th><fmt:message key='cz'/></th>
                    </tr>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1}</td>
                        <td>${item.shoppingCard.cardNo}</td>
                        <td>${item.user.username}</td>
                        <td><fmt:formatNumber value="${item.balance}" type="CURRENCY"/></td>
                        <td>
                            <c:if test="${item.source == 1}"><fmt:message key='gm'/></c:if>
                            <c:if test="${item.source == 2}"><fmt:message key='zs'/></c:if>
                        </td>
                        <td>
                            <c:if test="${item.status == 1}"><fmt:message key='ksy'/></c:if>
                            <c:if test="${item.status == 2}"><fmt:message key='yyw'/></c:if>
                            <c:if test="${item.status == 3}"><fmt:message key='yzz'/></c:if>
                            <c:if test="${item.status == 4}"><fmt:message key='ygq'/></c:if>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <c:if test="${item.status != 3}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs consume-list"><fmt:message key='xfjl'/></a>
                                </c:if>
                                <c:if test="${item.status == 3}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs card-recipient"><fmt:message key='zzyh'/></a>
                                </c:if>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['layer'], function () {

        var layer = layui.layer;

        /**
         * 转增用户
         */
        $(".card-recipient").click(function () {
            var id = $(this).attr("data-id");
            feijin.get({
                "url": "${web_domain}/mall/marketing/shoppingCard/recipient?id=" + id,
                "success": function (res) {
                    if (res.status) {
                        layer.open({
                            "title": "<fmt:message key='zzyh'/>",
                            "type": 1,
                            "area": ["400px", "180px"],
                            "content": "<p style='text-align: center; line-height: 30px; margin-top: 20px;'><fmt:message key='zzzh'/>：" + res.username +"</p><p style='text-align: center; line-height: 30px'><fmt:message key='zzsj'/>：" + res.recipientTime +"</p>"
                        })
                    }
                }
            });
        });

        /**
         * 消费记录
         */
        $(".consume-list").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                title: '<fmt:message key='xfjl'/>',
                content: '${web_domain}/mall/marketing/shoppingCard/' + id +'/consume',
                maxmin: true,
                area: ['95%', '95%'],
                btn: ['<fmt:message key='fh'/>']
            });
        });

    });

</script>
</body>
</fmt:bundle>
</html>